

/**
 * 获取一个名称的别名集合
 * @param {string} fullName 完整名称
 * @returns {Set<string>} 别名集合
 */
export function GetAliasSet(fullName) {
    // 清理和格式化输入名称
    let lowerFullName = '';
    for (let i = 0; i < fullName.length; i++) {
        let ch = fullName[i];
        ch = ch === '_' ? '-' : ch;
        
        if (lowerFullName.length === 0) {
            lowerFullName += ch.toLowerCase();
        } else if (ch === '-' && lowerFullName[lowerFullName.length - 1] === '-') {
            continue;
        } else if (ch >= 'A' && ch <= 'Z') {
            const lowerCh = ch.toLowerCase();
            if (lowerFullName.length === 0 || lowerFullName[lowerFullName.length - 1] === '-') {
                lowerFullName += lowerCh;
            } else {
                if (/[a-zA-Z0-9]/.test(lowerFullName[lowerFullName.length - 1])) {
                    lowerFullName += '-';
                }
                lowerFullName += lowerCh;
            }
        } else {
            lowerFullName += ch;
        }
    }

    // 提取单词列表
    const nameList = [];
    let name = '';
    for (const character of lowerFullName) {
        if (/[a-zA-Z]/.test(character) || (name.length > 0 && /[0-9]/.test(character))) {
            name += character;
        } else {
            if (name.length > 0) {
                nameList.push(name);
                name = '';
            }
        }
    }
    if (name.length > 0) {
        nameList.push(name);
    }

    if (nameList.length < 1) {
        return new Set();
    }

    // 生成不同格式的别名
    let standardAlias = '';   // xxx-xxx 标准格式
    let camelCaseAlias = '';  // xxxXxx 驼峰格式
    let pascalCaseAlias = ''; // XxxXxx 帕斯卡格式
    let snakeCaseAlias = '';  // xxx_xxx 下划线格式
    let fullLowerAlias = '';  // xxxxxx 全小写

    for (let i = 0; i < nameList.length; i++) {
        const word = nameList[i];
        if (i === 0) {
            standardAlias += word;
            snakeCaseAlias += word;
            camelCaseAlias += word;
            fullLowerAlias += word;
            pascalCaseAlias += word.charAt(0).toUpperCase() + word.slice(1);
        } else {
            standardAlias += "-" + word;
            snakeCaseAlias += "_" + word;
            fullLowerAlias += word;
            camelCaseAlias += word.charAt(0).toUpperCase() + word.slice(1);
            pascalCaseAlias += word.charAt(0).toUpperCase() + word.slice(1);
        }
    }

    // 返回包含所有别名的集合
    return new Set([
        standardAlias,
        camelCaseAlias,
        pascalCaseAlias,
        snakeCaseAlias,
        fullLowerAlias
    ]);
}